package com.wm.blog_gateway.config;

import lombok.Data;
import lombok.extern.slf4j.Slf4j;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Configuration;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Optional;

/***
 * @ClassName: GatewayWhiteConfig
 * @Description: 网关白名单
 * @Author: wm_yu
 * @Create_time: 10:24 2020-3-30
 */
@Configuration
@Data
@ConfigurationProperties(prefix = "ignores")
@Slf4j
public class GatewayWhiteConfig {

    /**
     * 不拦截的白名单
     */
    private List<String> whiteList;



    public String[] getAuthWhite(){
        List<String> list = Optional
                .ofNullable(this.whiteList)
                .orElse(new ArrayList<>());
        list.add("/actuator/**");
        String[] whiteAuth = new String[list.size()];
        String[] array = list.toArray(whiteAuth);
        log.info("白名单接口:{},JJJ:{}", Arrays.toString(array),whiteAuth);
        return array;
    }

}
